class Dog:
    def __init__(self, name):
        self.name = name

    def __str__(self):  # 直接打印Dog()时就会打印self.name
        return self.name

    def __repr__(self):  # 如果在会话终端直接输入Dog()会打印返回的内容
        return self.name

    def __eq__(self, other):  # 当Dog()对象遇到 == 时会触发这个函数，other是==号右边的对象
        return self.name.lower() == other.name.lower()


if __name__ == '__main__':
    dog1 = Dog('ahuang')
    dog2 = Dog('Ahuang')
    dog3 = Dog('Wangwang')

    print(dog1 == dog2)
    print(dog1 == dog3)

    print('I have %f yuan' % 35.7)  # 默认6位小数
    print('I have %10f yuan' % 35.7)  # 右对齐总共长度为10，不够用空格补齐
    print('I have %-10f yuan' % 35.7)  # 左对齐，长度为10， 不够用空格补齐
    print('I have %-10.3f yuan' % 35.7)  # 左对齐，长度为10， 不够用空格补齐， 并且设置小数位数为3位
    """
    I have 35.700000 yuan
    I have  35.700000 yuan
    I have 35.700000  yuan
    I have 35.700     yuan
    """

    print('I have {0: ^10.2f} yuan {0}'.format(35.5, 10))  # I have   35.50    yuan 35.5
    """
    用format语法时，可以直接用{}代替相应位置的变量，或者在{}中填入变量的索引，使该位置插入对应的内容，对于{}中冒号后面的，是修饰内容的展示，
    <左对齐，^据中显示, >右对齐，之间的数字和上面的一样
    """

